using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SysFrame.Message;
using System.Reflection;
using System.Data;
using MySql.Data.MySqlClient;

namespace SysFrame.BP
{
    /// <summary>
    /// system_3方法
    /// </summary>
    public class MySQLsystem_3: Isystem_3
    {

        /// <summary>
        /// 得到system_3实体
        /// </summary>
        /// <param name="msq">条件</param>
        /// <returns></returns>
        public List<Mssystem_3> Getsystem_3MsByQuery(MsQuery msq)
        {
            List<Mssystem_3> listms=new List<Mssystem_3>();
            StringBuilder sb = new StringBuilder();
            List<string> lstCmdText = new List<string>();
            sb.Append("select system_3.* ");
            sb.Append(" from system_3 ");
            sb.Append(" where 1=1 ").Append(msq.strquery);
            if(msq.strorder != null && msq.strorder != "")
            {
				sb.Append(" order by ").Append(msq.strorder);
            }
            lstCmdText.Add(sb.ToString());
            sb.Remove(0, sb.ToString().Length);
            try
            {
                DataSet ds = DbHelperMySQL.Query(lstCmdText[0].ToString());
               if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0)
                {
                	foreach(DataRow dr in ds.Tables[0].Rows)
                	{
                    	Mssystem_3 ms = new Mssystem_3();
                    	if(dr["System_3_10"].ToString()!=""){ms.System_3_10=int.Parse(dr["System_3_10"].ToString());}
                    	if(dr["System_3_20"]!=null){ms.System_3_20=dr["System_3_20"].ToString();}
                    	if(dr["System_3_30"]!=null){ms.System_3_30=dr["System_3_30"].ToString();}
                    	if(dr["System_3_40"]!=null){ms.System_3_40=dr["System_3_40"].ToString();}
                    	if(dr["System_3_50"]!=null){ms.System_3_50=dr["System_3_50"].ToString();}
                    	if(dr["System_3_60"]!=null){ms.System_3_60=dr["System_3_60"].ToString();}
                    	if(dr["System_3_70"]!=null){ms.System_3_70=dr["System_3_70"].ToString();}
                    	if(dr["System_3_80"]!=null){ms.System_3_80=dr["System_3_80"].ToString();}
                    	if(dr["System_3_90"]!=null){ms.System_3_90=dr["System_3_90"].ToString();}
                    	if(dr["System_3_100"]!=null){ms.System_3_100=dr["System_3_100"].ToString();}
                    	if(dr["System_3_110"]!=null){ms.System_3_110=dr["System_3_110"].ToString();}
                    	if(dr["System_3_120"]!=null){ms.System_3_120=dr["System_3_120"].ToString();}
                    	if(dr["System_3_130"]!=null){ms.System_3_130=dr["System_3_130"].ToString();}
                    	if(dr["System_3_140"]!=null){ms.System_3_140=dr["System_3_140"].ToString();}
                    	if(dr["System_3_150"]!=null){ms.System_3_150=dr["System_3_150"].ToString();}
                    	if(dr["System_3_160"]!=null){ms.System_3_160=dr["System_3_160"].ToString();}
                    	if(dr["System_3_170"]!=null){ms.System_3_170=dr["System_3_170"].ToString();}
                    	if(dr["System_3_180"]!=null){ms.System_3_180=dr["System_3_180"].ToString();}
                    	if(dr["System_3_190"]!=null){ms.System_3_190=dr["System_3_190"].ToString();}
                    	if(dr["System_9990"]!=null){ms.System_9990=DateTime.Parse(dr["System_9990"].ToString());}
                    	if(dr["System_9991"]!=null){ms.System_9991=dr["System_9991"].ToString();}
                    	if(dr["System_9992"]!=null){ms.System_9992=dr["System_9992"].ToString();}
                    	if(dr["System_9993"]!=null){ms.System_9993=dr["System_9993"].ToString();}
                    	if(dr["System_9994"]!=null){ms.System_9994=dr["System_9994"].ToString();}
                    	if(dr["System_9995"]!=null){ms.System_9995=dr["System_9995"].ToString();}
                    	listms.Add(ms);
                	}
                }
            }
            catch{}
            return listms;
        }

        /// <summary>
        ///  保存system_3信息
        /// </summary>
        /// <param name="ms">实体信息 通过System_3_10进行判断有System_3_10就是update</param>
        /// <returns>消息</returns>
        public MsReturned Savesystem_3(Mssystem_3 ms)
        {
            MsReturned msr = new MsReturned();
            if(ms.System_3_10 !=null && ms.System_3_10.ToString() !="" && ms.System_3_10.ToString() != "0")
            {
            	msr = Upsystem_3(ms);
            }
            else
            {
            	msr = Addsystem_3(ms);
            }
            return msr;
        }

        /// <summary>
        ///  新增system_3信息
        /// </summary>
        /// <param name="ms">实体信息 通过System_3_10进行判断有System_3_10就是update</param>
        /// <returns>消息</returns>
        public MsReturned Addsystem_3(Mssystem_3 ms)
        {
            List<string> lstResult = new List<string>();
            StringBuilder sb = new StringBuilder();
            List<string> lstCmdText = new List<string>();
            MsReturned msr = new MsReturned();
            int newRateId = DataBase.GetMaxId("system_3", "System_3_10");
            sb.Append("insert into system_3 (");
            sb.Append("System_3_10,System_3_20,System_3_30,System_3_40,System_3_50,");
            sb.Append("System_3_60,System_3_70,System_3_80,System_3_90,System_3_100,");
            sb.Append("System_3_110,System_3_120,System_3_130,System_3_140,System_3_150,");
            sb.Append("System_3_160,System_3_170,System_3_180,System_3_190,System_9990,");
            sb.Append("System_9991,System_9992,System_9993,System_9994,System_9995");
            sb.Append(")");
            sb.Append("values ( ");
            sb.Append(newRateId.ToString()).Append(",");
            sb.Append("@System_3_20,@System_3_30,@System_3_40,@System_3_50,");
            sb.Append("@System_3_60,@System_3_70,@System_3_80,@System_3_90,@System_3_100,");
            sb.Append("@System_3_110,@System_3_120,@System_3_130,@System_3_140,@System_3_150,");
            sb.Append("@System_3_160,@System_3_170,@System_3_180,@System_3_190,@System_9990,");
            sb.Append("@System_9991,@System_9992,@System_9993,@System_9994,@System_9995)");
            MySqlParameter[] parameters = {
            		new MySqlParameter("@System_3_10", MySqlDbType.Int32,11),
            		new MySqlParameter("@System_3_20", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_30", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_40", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_50", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_60", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_70", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_80", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_90", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_100", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_110", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_120", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_130", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_140", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_150", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_160", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_170", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_180", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_3_190", MySqlDbType.VarChar,200),
            		new MySqlParameter("@System_9990", MySqlDbType.DateTime),
            		new MySqlParameter("@System_9991", MySqlDbType.VarChar,1000),
            		new MySqlParameter("@System_9992", MySqlDbType.VarChar,1000),
            		new MySqlParameter("@System_9993", MySqlDbType.VarChar,1000),
            		new MySqlParameter("@System_9994", MySqlDbType.VarChar,1000),
            		new MySqlParameter("@System_9995", MySqlDbType.VarChar,1000)};
            parameters[0].Value = ms.System_3_10;
            parameters[1].Value = ms.System_3_20;
            parameters[2].Value = ms.System_3_30;
            parameters[3].Value = ms.System_3_40;
            parameters[4].Value = ms.System_3_50;
            parameters[5].Value = ms.System_3_60;
            parameters[6].Value = ms.System_3_70;
            parameters[7].Value = ms.System_3_80;
            parameters[8].Value = ms.System_3_90;
            parameters[9].Value = ms.System_3_100;
            parameters[10].Value = ms.System_3_110;
            parameters[11].Value = ms.System_3_120;
            parameters[12].Value = ms.System_3_130;
            parameters[13].Value = ms.System_3_140;
            parameters[14].Value = ms.System_3_150;
            parameters[15].Value = ms.System_3_160;
            parameters[16].Value = ms.System_3_170;
            parameters[17].Value = ms.System_3_180;
            parameters[18].Value = ms.System_3_190;
            parameters[19].Value = ms.System_9990;
            parameters[20].Value = ms.System_9991;
            parameters[21].Value = ms.System_9992;
            parameters[22].Value = ms.System_9993;
            parameters[23].Value = ms.System_9994;
            parameters[24].Value = ms.System_9995;
            lstCmdText.Add(sb.ToString());
            sb.Remove(0, sb.ToString().Length);
            try
            {
                int iexe = DbHelperMySQL.ExecuteSql(lstCmdText[0].ToString(),parameters);
                if (iexe > 0)
                {
                    msr.strMsId = newRateId.ToString();
                    msr.strMS = "保存成功!";
                }
                else
                {
                    msr.strMsId = "-1";
                    msr.strMS = "操作失败:服务器忙,请稍后再试!";
                }
            }
            catch
            {
                msr.strMsId = "-1";
                msr.strMS = "操作失败:服务器忙,请稍后再试!";
            }
            lstCmdText = null;
            sb = null;
            return msr;
        }

        /// <summary>
        ///  更新system_3信息
        /// </summary>
        /// <param name="ms">实体信息 通过System_3_10进行判断有System_3_10就是update</param>
        /// <returns>消息</returns>
        public MsReturned Upsystem_3(Mssystem_3 ms)
        {
            List<string> lstResult = new List<string>();
            StringBuilder sb = new StringBuilder();
            List<string> lstCmdText = new List<string>();
            MsReturned msr = new MsReturned();
           	sb.Append("update system_3 set ");
           	sb.Append(" System_3_10='").Append(ms.System_3_10).Append("' ");// System_3_10 
           	if (ms.System_3_20 !=null && ms.System_3_20.ToString() != ""){
           	    sb.Append(",").Append(" System_3_20='").Append(ms.System_3_20).Append("' ");// System_3_20 
           	}
           	if (ms.System_3_30 !=null && ms.System_3_30.ToString() != ""){
           	    sb.Append(",").Append(" System_3_30='").Append(ms.System_3_30).Append("' ");// System_3_30 
           	}
           	if (ms.System_3_40 !=null && ms.System_3_40.ToString() != ""){
           	    sb.Append(",").Append(" System_3_40='").Append(ms.System_3_40).Append("' ");// System_3_40 
           	}
           	if (ms.System_3_50 !=null && ms.System_3_50.ToString() != ""){
           	    sb.Append(",").Append(" System_3_50='").Append(ms.System_3_50).Append("' ");// System_3_50 
           	}
           	if (ms.System_3_60 !=null && ms.System_3_60.ToString() != ""){
           	    sb.Append(",").Append(" System_3_60='").Append(ms.System_3_60).Append("' ");// System_3_60 
           	}
           	if (ms.System_3_70 !=null && ms.System_3_70.ToString() != ""){
           	    sb.Append(",").Append(" System_3_70='").Append(ms.System_3_70).Append("' ");// System_3_70 
           	}
           	if (ms.System_3_80 !=null && ms.System_3_80.ToString() != ""){
           	    sb.Append(",").Append(" System_3_80='").Append(ms.System_3_80).Append("' ");// System_3_80 
           	}
           	if (ms.System_3_90 !=null && ms.System_3_90.ToString() != ""){
           	    sb.Append(",").Append(" System_3_90='").Append(ms.System_3_90).Append("' ");// System_3_90 
           	}
           	if (ms.System_3_100 !=null && ms.System_3_100.ToString() != ""){
           	    sb.Append(",").Append(" System_3_100='").Append(ms.System_3_100).Append("' ");// System_3_100 
           	}
           	if (ms.System_3_110 !=null && ms.System_3_110.ToString() != ""){
           	    sb.Append(",").Append(" System_3_110='").Append(ms.System_3_110).Append("' ");// System_3_110 
           	}
           	if (ms.System_3_120 !=null && ms.System_3_120.ToString() != ""){
           	    sb.Append(",").Append(" System_3_120='").Append(ms.System_3_120).Append("' ");// System_3_120 
           	}
           	if (ms.System_3_130 !=null && ms.System_3_130.ToString() != ""){
           	    sb.Append(",").Append(" System_3_130='").Append(ms.System_3_130).Append("' ");// System_3_130 
           	}
           	if (ms.System_3_140 !=null && ms.System_3_140.ToString() != ""){
           	    sb.Append(",").Append(" System_3_140='").Append(ms.System_3_140).Append("' ");// System_3_140 
           	}
           	if (ms.System_3_150 !=null && ms.System_3_150.ToString() != ""){
           	    sb.Append(",").Append(" System_3_150='").Append(ms.System_3_150).Append("' ");// System_3_150 
           	}
           	if (ms.System_3_160 !=null && ms.System_3_160.ToString() != ""){
           	    sb.Append(",").Append(" System_3_160='").Append(ms.System_3_160).Append("' ");// System_3_160 
           	}
           	if (ms.System_3_170 !=null && ms.System_3_170.ToString() != ""){
           	    sb.Append(",").Append(" System_3_170='").Append(ms.System_3_170).Append("' ");// System_3_170 
           	}
           	if (ms.System_3_180 !=null && ms.System_3_180.ToString() != ""){
           	    sb.Append(",").Append(" System_3_180='").Append(ms.System_3_180).Append("' ");// System_3_180 
           	}
           	if (ms.System_3_190 !=null && ms.System_3_190.ToString() != ""){
           	    sb.Append(",").Append(" System_3_190='").Append(ms.System_3_190).Append("' ");// System_3_190 
           	}
           	if (ms.System_9990 !=null && ms.System_9990.ToString() != ""){
           	    sb.Append(",").Append(" System_9990='").Append(ms.System_9990).Append("' ");// System_9990 
           	}
           	if (ms.System_9991 !=null && ms.System_9991.ToString() != ""){
           	    sb.Append(",").Append(" System_9991='").Append(ms.System_9991).Append("' ");// System_9991 
           	}
           	if (ms.System_9992 !=null && ms.System_9992.ToString() != ""){
           	    sb.Append(",").Append(" System_9992='").Append(ms.System_9992).Append("' ");// System_9992 
           	}
           	if (ms.System_9993 !=null && ms.System_9993.ToString() != ""){
           	    sb.Append(",").Append(" System_9993='").Append(ms.System_9993).Append("' ");// System_9993 
           	}
           	if (ms.System_9994 !=null && ms.System_9994.ToString() != ""){
           	    sb.Append(",").Append(" System_9994='").Append(ms.System_9994).Append("' ");// System_9994 
           	}
           	if (ms.System_9995 !=null && ms.System_9995.ToString() != ""){
           	    sb.Append(",").Append(" System_9995='").Append(ms.System_9995).Append("' ");// System_9995 
           	}
           	sb.Append(" where System_3_10='").Append(ms.System_3_10).Append("'");// System_3_10 
            lstCmdText.Add(sb.ToString());
            sb.Remove(0, sb.ToString().Length);
            try
            {
                int iexe = DbHelperMySQL.ExecuteSql(lstCmdText[0].ToString());
                if (iexe > 0)
                {
                    msr.strMsId = ms.System_3_10.ToString();
                    msr.strMS = "保存成功!";
                }
                else
                {
                    msr.strMsId = "-1";
                    msr.strMS = "操作失败:服务器忙,请稍后再试!";
                }
            }
            catch
            {
                msr.strMsId = "-1";
                msr.strMS = "操作失败:服务器忙,请稍后再试!";
            }
            lstCmdText = null;
            sb = null;
            return msr;
        }

        /// <summary>
        /// 得到数据类型
        /// </summary>
        /// <param name="msq">条件</param>
        /// <returns>数据类型</returns>
        public MsReturned Getsystem_3ByQuery(MsQuery msq)
        {
        	DataSet ds = null;
        	MsReturned msr = new MsReturned();
            StringBuilder sb = new StringBuilder();
            List<string> lstCmdText = new List<string>();
            sb.Append("select system_3.* ");
            sb.Append(" from system_3 ");
            sb.Append(" where 1=1 ").Append(msq.strquery);
            if(msq.strorder!=null && msq.strorder != "")
            {
				sb.Append(" order by ").Append(msq.strorder);
            }
            lstCmdText.Add(sb.ToString());
            sb.Remove(0, sb.ToString().Length);
            try
            {
                ds = DbHelperMySQL.Query(lstCmdText[0].ToString());
            }
            catch{}
            msr.data = ds;
            return msr;
        }

        /// <summary>
        /// 删除system_3
        /// </summary>
        /// <param name="msq">条件</param>
        /// <returns></returns>
        public MsReturned Deletesystem_3ByQuery(MsQuery msq)
        {
            StringBuilder sb = new StringBuilder();
            MsReturned msr = new MsReturned();
            sb.Append(" delete from system_3 where System_3_10 > 0 ").Append(msq.strquery);
            try
            {
                int iexe = DbHelperMySQL.ExecuteSql(sb.ToString());
                if (iexe > 0)
                {
                    msr.strMsId = "1";
                    msr.strMS = "保存成功!";
                }
                else
                {
                    msr.strMsId = "-1";
                    msr.strMS = "操作失败:服务器忙,请稍后再试!";
                }
            }
            catch
            {
                msr.strMsId = "-1";
                msr.strMS = "操作失败:服务器忙,请稍后再试!";
            }
            sb = null;
            return msr;
        }

    }
}
